package com.cnhis.cloudhealth.clinical.hosnurse.hospathway.bo;

import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.cnhis.cloudhealth.clinical.hosnurse.hospathway.dao.HosPathWayDao;
import com.cnhis.cloudhealth.commons.Mappers.ModelVo;
import com.cnhis.cloudhealth.commons.utils.StaticKeys;

@Service
public class HosPathWayBo {
  @Resource
  private HosPathWayDao hosPathWayDao;
  
  public ModelVo pathWayMethod()throws Exception{
	  ModelVo mo = new ModelVo();
		List list =null;
		try {
			list=hosPathWayDao.pathWayMethod();
			
		} catch (Exception e) {
			e.printStackTrace();
			mo.setResult(StaticKeys.OH_FALSE);
			return mo;
		}
		mo.setList(list);
		mo.setResult(StaticKeys.OH_SUCCESS);
		mo.setRows(list);
		return mo;
  }
  public ModelVo pathWayExecutor()throws Exception{
	  ModelVo mo = new ModelVo();
		List list =null;
		try {
			list=hosPathWayDao.pathWayExecutor();
			
		} catch (Exception e) {
			e.printStackTrace();
			mo.setResult(StaticKeys.OH_FALSE);
			return mo;
		}
		mo.setList(list);
		mo.setResult(StaticKeys.OH_SUCCESS);
		mo.setRows(list);
		return mo;
  }
  private Map getBIG07(Map map)throws Exception{
	  return hosPathWayDao.getBIG07(map);
  }
  private int getBIG01(Map map)throws Exception{
	  return hosPathWayDao.getBIG01(map);
  }
  @SuppressWarnings("unchecked")
public ModelVo queryCarePath(Map map)throws Exception{
	  ModelVo mo = new ModelVo();
		List list =null;
		try {
			Map m = getBIG07(map);
			if(m!=null){
			map.put("BIG07", m.get("big07"));
			map.put("BIB01", m.get("bib01"));
			map.put("BIG01", m.get("big01"));
			map.put("vcn01", m.get("vcn01"));
			}
			map.put("BIG01", getBIG01(map));
			list=hosPathWayDao.queryCarePath(map);
			
		} catch (Exception e) {
			e.printStackTrace();
			mo.setResult(StaticKeys.OH_FALSE);
			return mo;
		}
		mo.setList(list);
		mo.setResult(StaticKeys.OH_SUCCESS);
		mo.setRows(list);
		return mo;
  }
  public ModelVo queryPathWaySummary(Map map)throws Exception{
	  ModelVo mo = new ModelVo();
		List list =null;
		try {
			list=hosPathWayDao.queryPathWaySummary(map);
			
		} catch (Exception e) {
			e.printStackTrace();
			mo.setResult(StaticKeys.OH_FALSE);
			return mo;
		}
		mo.setList(list);
		mo.setResult(StaticKeys.OH_SUCCESS);
		mo.setRows(list);
		return mo;
  }
  private Map params(Map map)throws Exception{
	  return hosPathWayDao.params(map);
  }
  @SuppressWarnings("unchecked")
public ModelVo pathExecute(Map map)throws Exception{
	  ModelVo mo = new ModelVo();
		List list =null;
		try {
			Map m = params(map);
			if(m!=null){
				map.put("BIG07", m.get("big07"));
				map.put("BIB01", m.get("bib01"));
				map.put("BIG01", m.get("big01"));
				map.put("BIG01", hosPathWayDao.BIG01(map));
			}
			list=hosPathWayDao.pathExecute(map);
			
		} catch (Exception e) {
			e.printStackTrace();
			mo.setResult(StaticKeys.OH_FALSE);
			return mo;
		}
		mo.setList(list);
		mo.setResult(StaticKeys.OH_SUCCESS);
		mo.setRows(list);
		return mo;
  }
}
